<?php
/**
 * @file test018.php
 * @package taobaoke
 * @subpackage 
 * @version $id: 0.1 UTF-8 2009-8-12 下午10:02:19 $
 * @author LD King (mifunny.info)
 * @copyright Copyright (c) 2007 - 2009 MiFunny China Inc. (http://mifunny.info)
 * 
 * 批量更新数据表
 * `tURL`中的`status`， 0没有链接， 但是wp_post表正确
 * 					3wp_post表错误， url存在
 * 					1完美发布
 * 					2准备状态！！！
 * 
 * 
 */
require_once 'config.inc.php';
try{ //数据库保持长连接
		$dbh = new PDO('mysql:host='.DB_HOST.';dbname='.DB_NAME, DB_USER, DB_PASSWORD, array(PDO::ATTR_PERSISTENT => true));
			$dbh->query('set names '.DB_CHARSET.';');
			
	
			$sql1 = "SELECT `wp_id` , `content` FROM `tURL` WHERE `status` = 3 LIMIT 0 , 1000";
			$re1 = $dbh->query($sql1)->fetchAll(PDO::FETCH_ASSOC);
			foreach ($re1 as $re) {
				$wp_id = $re['wp_id'];
				$content = $re['content'];
				$status = 2;			
				$sql2 = "update `wp_posts` set `post_content`  = '{$content}'  WHERE `ID` = '{$wp_id}'  LIMIT 1 ;";
				if( !empty($content) )
					$reu = $dbh->query($sql2);
				else $status = 0;
				echo "{$wp_id}- <br />";
				
				$sql3 = "UPDATE `tURL` SET `status` = {$status}  WHERE `wp_id`  = {$wp_id}  LIMIT 1 ;";
				$rer = $dbh->query($sql3);
			}
			
			/*		
			$sql1 = "SELECT `wp_id` , `content` FROM `tURL` WHERE `status` = 2 and  `content` = '' LIMIT 0 , 1000";
			$re1 = $dbh->query($sql1)->fetchAll(PDO::FETCH_ASSOC);
			foreach ($re1 as $re) {
				$wp_id = $re['wp_id'];
				$content = $re['content'];
				$status = 0;			
				if( empty($content) ){
							$sql3 = "UPDATE `tURL` SET `status` = {$status}  WHERE `wp_id`  = {$wp_id}  LIMIT 1 ;";
				$rer = $dbh->query($sql3);			
				echo "{$wp_id}- <br />";	
				}
			}			*/
			
}catch(Exception $e){
 			die( "MySQL Conneting Failed: " . $e->getMessage() );
}





?>